package com.buka.controller;

import com.buka.domain.ResponseResult;
import com.buka.dto.UserDto;
import com.buka.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/system/user/list")
    public ResponseResult list(int pageNum, int pageSize, String phonenumber, String status) {
        return userService.list(pageNum, pageSize, phonenumber, status);
    }

    @PostMapping("/system/user")
    public ResponseResult add(@RequestBody UserDto userDto) {
        return userService.add(userDto);
    }

    @GetMapping("/system/user/{id}")
    public ResponseResult get(@PathVariable("id") int id) {
        return userService.get(id);
    }

    @PutMapping("/system/user")
    public ResponseResult update(@RequestBody UserDto userDto) {
        return userService.update(userDto);
    }

    @DeleteMapping("/system/user/{id}")
    public ResponseResult delete(@PathVariable("id") int id) {
        return userService.delete(id);
    }

}
